package com.java2_22_1;

public class java2_22_test {
    //    public static void main(String[] args) {
//        Lecturer l = new Lecturer(1,"zhangsan","讲师");
//        System.out.println(l.toString());
//        l.work();
//
//
//    }
//    public static void main(String[] args) {
//        Teacher1 t = new Teacher1("zhangsan",29,"教学部");
//        t.publishFrom();
//        Student s = new Student("lisi",18,"二班");
//        s.fillFrom();
//
//    }
//    public static void main(String[] args) {
//        Phone p = new Phone("苹果",10000);
//        System.out.println(p.toString());
//    }
//    public static void main(String[] args) {
//        PetOwner owner = new PetOwner("zhangsan",33);
//        Dog dog = new Dog(4,"土黄色");
//        owner.keepPet(dog,"好吃的大骨头");
//        System.out.println(dog.toString());
//
//
//    }
//    public static void main(String[] args) {
////        Animal animal = new Dog(4,"黑色");
////        System.out.println(animal.getColor());
////        System.out.println(animal.getAge());
////        System.out.println(animal.toString());
////        //创建完之后还是Animal类型的,但是不能使用子类的特殊方法
////        if(animal instanceof Dog dog){
////            dog.lookHome();
////        }
////        //instanceof是看前面的对象是否是后面的类型或类型的子类所创建的
//        Cat cat = new Cat();
//        show(cat);
//    }
//    public static void show(Animal animal){
//        if(animal instanceof Dog ){
//            System.out.println("dog");
//        }
//        if(animal instanceof Cat){
//            System.out.println("cat");
//        }
//    }
//    public static void main(String[] args) {
//        int a = 10;
//        int b = 20;
//        System.out.println(MyMath.add(a, b));
//        System.out.println(MyMath.del(a, b));
//        System.out.println(MyMath.mul(a, b));
//        System.out.println(MyMath.div(a, b));
//
//
//    }
//    public static void main(String[] args) {
//        Round r = new Round(2);
//        Rectangle re = new Rectangle(2,3);
//        System.out.println(r.getArea());
//        System.out.println(r.getCircumference());
//        System.out.println(re.getArea());
//        System.out.println(re.getCircumference());
//
//
//    }
//    public static void main(String[] args) {
//        NewTelePhone nt = new NewTelePhone();
//        OldTelePhone ot = new OldTelePhone();
//        usePhone(nt);
//        System.out.println("---------------------------");
//        usePhone(ot);
//    }
//    public static void usePhone(TelePhone telePhone){
//        telePhone.call();
//        telePhone.sendMessage();
//        if(telePhone instanceof NewTelePhone newTelePhone){
//            newTelePhone.play();
//        }
//    }
//    public static void main(String[] args) {
////        TestIplay1 t = new TestIplay1();
////        t.playGame();
//        IPlay1 i = new IPlay1(){
//            @Override
//            public void playGame() {
//                System.out.println("这是使用匿名内部类的实现类对象重写的playGame方法");
//            }
//        };//.playGame();
//        i.playGame();
//    }
    public static void main(String[] args) {
//        testFun tf = new testFun();
//        tf.fun();
        //只使用一次时使用匿名内部类

        Fun f = new Fun(){
            @Override
            public void fun() {
                System.out.println("重写重写重写重写重写重写");
            }
        };
        f.fun();



    }


}
